package com.example.keli.ui.my.love;

import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.example.keli.R;
import com.example.keli.base.BaseActivity;
import com.example.keli.base.utils.DensityUtil;
import com.example.keli.ui.my.adapter.LoveDetailAdapter;
import com.example.keli.ui.my.model.LoveReciveBean;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class LoveDetailActivity extends BaseActivity {


    @BindView(R.id.recycler_love_detail)
    RecyclerView mRecycler;
    @BindView(R.id.tv_love_title)
    TextView tvLoveTitle;
    @BindView(R.id.tv_love_num)
    TextView tvLoveNum;

    private List<LoveReciveBean.DataBean.UserInfoBean> mDataList;
    private LoveDetailAdapter mAdapter;

    @Override
    protected int layoutId() {
        return R.layout.activity_love_detail;
    }

    @Override
    protected void bindData() {
//        setTitle("喜欢我的");
        abTitle.setText("喜欢我的");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        mDataList = new ArrayList<>();
        LoveReciveBean.DataBean dataBean = (LoveReciveBean.DataBean) getIntent().getSerializableExtra("recive_love");
        if (dataBean != null){
            mDataList.addAll(dataBean.getUserInfo());
            mAdapter = new LoveDetailAdapter(mDataList, this);
            mRecycler.setLayoutManager(new LinearLayoutManager(this));
            mRecycler.setAdapter(mAdapter);
            mRecycler.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this)
                    .color(ContextCompat.getColor(this, R.color.divider_line))
                    .size(DensityUtil.dip2px(this, 1))
                    .build());
            tvLoveTitle.setText(dataBean.getTitle());
            tvLoveNum.setText(dataBean.getLike_num()+"人");
        }
    }

}
